<%-- 
    Document   : db1
    Created on : 2014/8/19, 下午 01:26:13
    Author     : gjun
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
    Class.forName("com.mysql.jdbc.Driver");//貼上資料庫路徑Driver/jdbc:mysq1.......
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/javadb", "root", "root");
    Statement st=con.createStatement();
    String sql="select id,username,tel,birthday from person";//可查詢list from mysql

%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>db4</title>
    </head>
    <body><center>
        <h1>db4</h1>
        <%
                    ResultSet rs=st.executeQuery(sql);//ResultSet要import
                    while(rs.next()){
                        String id=rs.getString("id");
                        String username=rs.getString("username");
                        String tel=rs.getString("tel");
                        String birthday=rs.getString("birthday");
                        out.println(id+","+username+","+tel+","+birthday+"<br>");                    
                    }
                    rs.close();//呼叫過 要關起來
                    st.close();
                    con.close();
         %>
    </center>             
    </body>
</html>
